cmake_minimum_required(VERSION 3.14)

project(qtxlsx LANGUAGES CXX)
message(${CMAKE_PROJECT_NAME}/${PROJECT_NAME} "项目开始：............................")
option(QTXLSX_LIBRARY "QTXLSX_LIB" ON)

set(ZIP_STD ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(OS ${CMAKE_SYSTEM_NAME})
set(QT_USE_QSTRINGBUILDER ON)

set(LIBRARY_OUTPUT_PATH ${qt6xlsx_SOURCE_DIR}/lib)    #库生成目录

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Core5Compat)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Core5Compat)

message(CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR})
aux_source_directory(. SRC_FILES)
file(GLOB_RECURSE HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
file(COPY ${HEADER_FILES} DESTINATION ${qt6xlsx_SOURCE_DIR}/include )

add_library(${PROJECT_NAME} SHARED
    ${SRC_FILES}
    ${HEADER_FILES}
)

if(CMAKE_BUILD_TYPE AND (CMAKE_BUILD_TYPE STREQUAL "Debug"))
    set(CMAKE_DEBUG_POSTFIX "_debug")
    message("设置调试输出文件的后缀: " ${CMAKE_DEBUG_POSTFIX})
    set_target_properties(${PROJECT_NAME} PROPERTIES
                          DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
endif()

target_link_libraries(${PROJECT_NAME}
    PRIVATE Qt${QT_VERSION_MAJOR}::Core
            Qt${QT_VERSION_MAJOR}::Gui
            Qt${QT_VERSION_MAJOR}::Core5Compat
)

target_compile_definitions(${PROJECT_NAME} PRIVATE QTXLSX_LIBRARY)

message("项目目录：" ${PROJECT_SOURCE_DIR})
message("构造目录：" ${PROJECT_BINARY_DIR})
message("生成目录：" ${LIBRARY_OUTPUT_PATH})
message(${CMAKE_PROJECT_NAME}/${PROJECT_NAME} "项目结束：----------------------------")
message("")
